import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86186
 * Date: 2023-10-06
 * Time: 11:59
 */
public class Test2 {
    public static void main(String[] args) throws InterruptedException {
        AtomicInteger atomicInteger = new AtomicInteger(0);
        Thread t1 = new Thread(() -> {
            for(int i = 0; i < 30; i++) {
                atomicInteger.getAndIncrement();
            }
        });

        Thread t2 = new Thread(() -> {
            for(int i = 0; i < 50; i++) {
                atomicInteger.getAndIncrement();
            }
        });

        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(atomicInteger.get());
    }

    ThreadPoolExecutor.DiscardOldestPolicy
}
